import request from '@/utils/request'
import { getGiteeSetting } from "@/api/settings";

const giteeSetting = getGiteeSetting()

// https://gitee.com/api/v5/swagger

export function get(path){
    let { access_token, owner, repo } = giteeSetting
    return request({
        url: '/api/v5/repos/' + owner + '/'+ repo +'/contents/' + path,
        method: 'get',
        params: { access_token }
    })
}

export function put(path, content, message, sha){
    let { access_token, owner, repo } = giteeSetting
    return request({
        url: '/api/v5/repos/' + owner + '/'+ repo +'/contents/' + path,
        method: 'put',
        data: { access_token, content, message, sha }
    })
}

export function post(path, content, message){
    let { access_token, owner, repo } = giteeSetting
    return request({
        url: '/api/v5/repos/' + owner + '/'+ repo +'/contents/' + path,
        method: 'post',
        data: { access_token, content, message }
    })
}